<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数字比较器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #f0f0f0;
            min-height: 100vh;
            margin: 0;
            padding: 20px;
        }

        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            width: 300px;
        }

        .input-group {
            margin-bottom: 20px;
        }

        input {
            width: 100%;
            padding: 8px;
            margin-top: 5px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }

        button {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }

        button:hover {
            background-color: #45a049;
        }

        #result {
            margin-top: 20px;
            padding: 15px;
            border-radius: 4px;
            text-align: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 style="text-align: center; margin-bottom: 20px;">数字比较器</h2>
        
        <div class="input-group">
            <label>第一个数字：</label>
            <input type="number" id="num1" placeholder="请输入数字">
        </div>

        <div class="input-group">
            <label>第二个数字：</label>
            <input type="number" id="num2" placeholder="请输入数字">
        </div>

        <button onclick="compareNumbers()">比较大小</button>

        <div id="result"></div>
    </div>

    <script>
        function compareNumbers() {
            // 获取输入值
            const num1 = parseFloat(document.getElementById('num1').value);
            const num2 = parseFloat(document.getElementById('num2').value);
            const resultDiv = document.getElementById('result');

            // 检查输入是否有效
            if (isNaN(num1) || isNaN(num2)) {
                resultDiv.innerHTML = "请输入有效的数字！";
                resultDiv.style.backgroundColor = "#ffebee";
                resultDiv.style.color = "#d32f2f";
                return;
            }

            // 比较数字
            if (num1 > num2) {
                resultDiv.innerHTML = `${num1} 大于 ${num2}`;
                resultDiv.style.backgroundColor = "#e3f2fd";
                resultDiv.style.color = "#1976d2";
            } else if (num1 < num2) {
                resultDiv.innerHTML = `${num1} 小于 ${num2}`;
                resultDiv.style.backgroundColor = "#e3f2fd";
                resultDiv.style.color = "#1976d2";
            } else {
                resultDiv.innerHTML = "两个数字相等";
                resultDiv.style.backgroundColor = "#f0f4c3";
                resultDiv.style.color = "#827717";
            }
        }
    </script>
</body>
</html>